<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

class CreateGameRecordsTable extends Migration
{
    private $table = 'game_records';

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create($this->table, function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('game_id')->comment('游戏记录id');
            $table->unsignedInteger('user_id')->comment('击球人id');
            $table->unsignedInteger('shot')->default(0)->comment('回合挥杆次数');
            $table->tinyInteger('distance')->default(0)->comment('洞口距离，0表示进洞');
            $table->timestamps();
        });

        DB::statement("ALTER TABLE `{$this->table}` COMMENT '游戏回合记录表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists($this->table);
    }
}
